﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BlueCrest.ConfigManagement.Storage;
using BlueCrest.ConfigManagement.Storage.DB.Service;
using NUnit.Framework;

namespace BlueCrest.ConfigManagement.ORM.NHibernate.Tests.Services
{
    [TestFixture, Category("Integration")]
    public class DbConfigStorageServiceIntegrationTests
    {
        private IConfigStorageService _dbConfigStorageService;

        [SetUp]
        public void SetUp()
        {
            _dbConfigStorageService = new DbConfigStorageService(new NHibernateSessionFactory(), new ConfigPathAdapterService());
        }

        [Test]
        public void CanGetScopes()
        {
            var items = _dbConfigStorageService.GetScopes();

            Assert.IsNotEmpty(items);
        }

        [Test]
        public void CanGetAllConfigPath()
        {
            var items = _dbConfigStorageService.GetAllConfigPath();

            Assert.IsNotEmpty(items);
        }

        [Test]
        public void CanGetConfigPathStartingFrom()
        {
            var items = _dbConfigStorageService.GetConfigPathStartingFrom(1);

            Assert.IsNotEmpty(items);
        }

        [Test]
        public void CanGetConfigPathStartingFromWithDepth()
        {
            var items = _dbConfigStorageService.GetConfigPathStartingFrom(1,1);

            Assert.IsNotEmpty(items);

            //should only got Root -> Level1 Child and that's it
            Assert.AreEqual(0, items[0].Children[0].Children.Count);
        }

        [Test]
        public void CanGetEntries()
        {
            var items = _dbConfigStorageService.GetEntries(1);

            Assert.IsNotEmpty(items);
        }
    }
}
